local najia = fk.CreateSkill{
  name = "plum__najia",
}

Fk:loadTranslationTable{
  ["plum__najia"] = "纳甲",
  [":plum__najia"] = "当你成为【杀】的唯一目标后，若你未装备防具牌，你可连续进行四次判定，且若结果为：黑色，你摸一张牌，令此【杀】额外生效一次；红色，令此【杀】少生效一次。",

  ["$plum__najia1"] = "兼三才而两之，易六画而成卦。",
  ["$plum__najia2"] = "分阴阳，用刚柔，易六位而成章。",
}

najia:addEffect(fk.TargetConfirmed, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(najia.name) and data.card.trueName == "slash"
    and #data.use:getAllTargets() == 1 and #player:getEquipments(Card.SubtypeArmor) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local red, black = 0, 0
    for i = 1, 4, 1 do
      room:broadcastPlaySound("./packages/standard_cards/audio/card/eight_diagram")
      room:setEmotion(player, "./packages/standard_cards/image/anim/eight_diagram")
      local judgeData = {
        who = player,
        reason = najia.name,
        pattern = ".|.|heart,diamond",
      }
      room:judge(judgeData)
      if judgeData.card.color == Card.Red then
        red = red + 1
      elseif judgeData.card.color == Card.Black then
        player:drawCards(1, najia.name)
        black = black + 1
      end
    end
    local n = black - red
    if n > 0 then
      data.use.additionalEffect = (data.use.additionalEffect or 0) + n
    elseif n < 0 then
      data.use.nullifiedTargets = data.use.nullifiedTargets or {}
      table.insertIfNeed(data.use.nullifiedTargets, player)
    end
  end,
})

return najia